const { shared } = wx.worklet

Page({
  data: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const x = shared(0)
    const y = shared(0)

    this.applyAnimatedStyle('.circle', () => {
      'worklet'
      return {
        transform: `translate(${x.value}px, ${y.value}px)`
      }
    })

    this.x = x
    this.y = y
  },

  handleHorizontalDrag(evt) {
    'worklet'
    console.log('横向拖动', evt)
    console.log(this.x)
    this.x.value += evt.deltaX
  },
  handleVertialDrag(evt) {
    'worklet'
    console.log('纵向移动', evt)
    console.log(this.y)
    this.y.value += evt.deltaY
  }
})
